home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / TYPEAHEA.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  64 lines

  1. #define        CURSES_LIBRARY  1
  2. #include <curses.h>
  3. #undef typeahead
  4.  
  5. #ifndef NDEBUG
  6. char *rcsid_typeahea = "$Header: c:/curses/portable/RCS/typeahea.c%v 2.0 1992/11/15 03:29:19 MH Rel $";
  7. #endif
  8.  
  9. extern short   c_pindex;               /* putter index                 */
  10. extern short   c_gindex;               /* getter index                 */
  11. extern short   c_ungind;               /* wungetch() push index        */
  12. extern chtype  c_ungch[NUNGETCH];      /* array of ungotten chars      */
  13. extern WINDOW* _getch_win_;
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   typeahead()  - check for type-ahead
  18.  
  19.   X/Open Description:
  20.        The curses package does the "line-breakout optimisation" by
  21.        looking for type-ahead periodically while updating the screen.
  22.        If input is found, the current update will be postponed until
  23.        refresh() or doupdate() are called again.  This allows faster
  24.        response to commands typed in advance.  Normally, the input FILE
  25.        pointer passed to newterm(), or stdin in the case when initscr()
  26.        was called, will be used to do this type-ahead checking.  The
  27.        typeahead() routine specified that the file descriptor fd is to
  28.        be used to check for type-ahead instead.  If fd is -1, then no
  29.        type-ahead checking will be done.
  30.  
  31.   PDCurses Description:
  32.        Some early versions of the library (1.5beta) may have had an
  33.        improper interface declaration.  e.g. bool typeahead( void );
  34.        rather than the X/Open specified bool typeahead( FILE* fd );.
  35.  
  36.        FYI:  Under PDCurses, the passed file handle fd is ignored.
  37.  
  38.   X/Open Return Value:
  39.        The typeahead() routine returns TRUE if keyboard input is pending
  40.        otherwise FALSE is returned.
  41.  
  42.   Portability:
  43.        PDCurses        bool typeahead( FILE* fd );
  44.        SysV Curses     
  45.        BSD Curses      
  46.        X/Open Dec '88  bool typeahead( FILE* fd );
  47.  
  48. **man-end**********************************************************************/
  49.  
  50. bool   typeahead( FILE* fd )
  51. {
  52. #ifdef TC
  53. #  pragma argsused
  54. #endif
  55.        if (c_ungind)
  56.                return (TRUE);                  /* ungotten char */
  57.        if (c_pindex > c_gindex)
  58.                return (TRUE);                  /* buffered char */
  59.        if (_cursvar.raw_inp)
  60.                return((bool)PDC_check_bios_key());/* raw mode test */
  61.  
  62.        return((bool)PDC_check_bios_key());     /* normal mode test */
  63. }
  64.